package com;

import com.mapper.CCcMapper;
import com.mapper.SStudentMapper;
import com.pojo.CCc;
import com.pojo.SStudent;
import com.util.MybatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

public class SStudentTest {
    @Test
    public void findWorkerByIdTest() {

        SqlSession sqlSession = MybatisUtils.getSession();
        SStudentMapper sStudentMapper = sqlSession.getMapper(SStudentMapper.class);
        SStudent worker = sStudentMapper.selectByPrimaryId(1);
        System.out.println(worker.toString());
        sqlSession.close();
    }
    @Test
    public void updateStudentTest() {
        SqlSession sqlSession = MybatisUtils.getSession();
        SStudent student = new SStudent();
        student.setId(4);
        student.setName("李雷");
        student.setAge(21);
        SStudentMapper sStudentMapper = sqlSession.getMapper(SStudentMapper.class);
        int result = sStudentMapper.updateNameAndAge(student);
        if (result >0) {
            System.out.println("成功");
        }else {
            System.out.println("失败");
        }
        System.out.println(student);
        sqlSession.commit();
        sqlSession.close();
    }
    @Test
    public void ssStudentTest() {
        SqlSession sqlSession = MybatisUtils.getSession();
        CCcMapper cCcMapper = sqlSession.getMapper(CCcMapper.class);
        CCc cCc = cCcMapper.selectByCid(2);
        System.out.println(cCc.toString());
        sqlSession.close();
    }
}
